package com.refactor.impl;

import com.refactor.dto.ResultDto;
import com.refactor.enums.MovieTypes;
import com.refactor.practice.Rental;


public class ChildrensHander extends PointHandler {
    public ChildrensHander(Integer type) {
        super(type);
    }

    @Override
    public ResultDto hanler(Rental rental) {
        double thisAmount = 0D;
        int frequentRenterPoints = 0;

        thisAmount += 1.5;
        if (rental.getDayRented() > 3) {
            thisAmount += (rental.getDayRented() - 3) * 1.5;
        }

        frequentRenterPoints++;
        //add bonus for a two day new release rental
        if ((this.type== MovieTypes.NEW_RELEASE.getType()) &&
                rental.getDayRented() > 1) {
            frequentRenterPoints++;
        }
        String result = "\t" + rental.getMovie().getTitle() +
                "\t" + String.valueOf(thisAmount) + "\n";

        return new ResultDto(result,frequentRenterPoints,thisAmount);
    }
}
